﻿<%@ Page Language="C#" MasterPageFile="~/Manager.master" AutoEventWireup="true" CodeFile="Menu.aspx.cs"
    Inherits="Manager_Menu_Menu" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table width="100%" cellpadding="2" cellspacing="0">
        <tr>
            <td align="left">
                <table border="1" bordercolor="#407db3" cellpadding="2" cellspacing="2" class="tbl_Comon-Search"
                    style="border-collapse: collapse" width="100%">
                    <tr>
                        <td align="center" colspan="1" rowspan="1" valign="top" nowrap="nowrap">
                            <asp:Button ID="btnReturn" runat="server" CssClass="cssButton" OnClick="btnReturn_Click"
                                Text="Quay lại" Visible="False" />
                            <asp:Button ID="btnSearch" runat="server" CssClass="cssButton" OnClick="btnSearch_Click1"
                                Text="Tìm kiếm" /></td>
                        <td class="td_Title" nowrap="nowrap" style="width: 85px">
                            <asp:Label ID="Label3" runat="server" CssClass="lbl_Common-Search" Text="Tên Menu"></asp:Label></td>
                        <td class="td_Control" style="width: 3380px">
                            <asp:TextBox ID="txtTenChuDe" runat="server" Width="98%"></asp:TextBox></td>
                        <td class="td_Title" style="width: 319px">
                            <asp:Label ID="Label1" runat="server" CssClass="lbl_Common-Search" Text="Loại Menu"></asp:Label></td>
                        <td class="td_Control" style="width: 280px">
                            <asp:DropDownList ID="ddlKindNo" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlKindNo_SelectedIndexChanged">
                                <asp:ListItem Value="A">Admin</asp:ListItem>
                                <asp:ListItem Value="H">Home</asp:ListItem>
                            </asp:DropDownList></td>
                    </tr>
                    <tr>
                        <td align="left" colspan="7" rowspan="1" valign="top">
                            <input id="btnSort" class="cssButton" type="button" value="Sắp xếp menu" onclick="openSeq()" />
                            <asp:Button ID="btnAdd_Catalogue" runat="server" CssClass="cssButton" OnClick="btnAdd_Catalogue_Click"
                                Text="Thêm mới" /></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <asp:GridView ID="grv_Master" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="menuID" Width="100%" CellPadding="2"
                    BorderColor="#407db3" OnRowCreated="grv_Master_RowCreated" OnRowDataBound="grv_Master_RowDataBound"
                    OnRowEditing="grv_Master_RowEditing" OnRowCancelingEdit="grv_Master_RowCancelingEdit"
                    OnRowUpdating="grv_Master_RowUpdating" OnRowDeleting="grv_Master_RowDeleting"
                    PageSize="20" OnPageIndexChanging="grv_Master_PageIndexChanging">
                    <Columns>
                        <asp:CommandField CancelImageUrl="~/Images/Icon/cmdCancel.gif" EditImageUrl="~/Images/Icon/cmdEdit.gif"
                            ShowEditButton="True" UpdateImageUrl="~/Images/Icon/Save.gif" ButtonType="Image">
                            <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Center" Wrap="False" />
                            <HeaderStyle CssClass="cssBorderGrv" />
                        </asp:CommandField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:LinkButton ID="lblDelete" runat="server" CommandName="delete" Text="<img src=../../Images/Icon/cmdDelete.gif border=0 alt=Delete > "></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Center" Width="10px" />
                            <HeaderStyle CssClass="cssBorderGrv" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                Tên Menu
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblMenuName" runat="server" Text='<%# Eval("MenuName") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtETenMn" runat="server" Text='<%# Eval("MenuName") %>' Width="95%"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Left" Width="30%" />
                            <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                Link
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Eval("MenuURL") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtEMenuURL" runat="server" Text='<%# Eval("MenuURL") %>' Width="95%"></asp:TextBox>
                            </EditItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Left" Width="40%" />
                            <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                Cấp menu
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblLevelMenu" runat="server" Text=''></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlLevelMenu" runat="server" DataSource="<%#Bind_Edit_DropList_Menu() %>"
                                    DataTextField="MenuName" DataValueField="MenuID">
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Left" Width="20%" />
                            <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                Loại menu
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblKindNo" runat="server" Text='<%# Eval("KindNo") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlEKindNo" runat="server">
                                    <asp:ListItem Text="Admin" Value="A">                            
                                    </asp:ListItem>
                                    <asp:ListItem Text="Home" Value="H">                            
                                    </asp:ListItem>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Left" Width="12%" />
                            <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Left" />
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle CssClass="gvRowStyle" />
                    <AlternatingRowStyle CssClass="gvAlternatingRowStyle" />
                    <HeaderStyle CssClass="gvHeader" />
                </asp:GridView>
            </td>
        </tr>
    </table>
    <input type="hidden" value="0" runat="server" id="hChoose" />
    <input type="hidden" runat="server" id="hPccMsg" />

    <script language="javascript" type="text/javascript">
	        var windowSort;
            function openSeq()
			{
				var width =750
				var height =500
				

				var left = parseInt((screen.availWidth/2) - (width/2));
				var top = parseInt((screen.availHeight/2) - (height/2));
				var feature = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top + ",menu=0,scrollbars=0,status=1,location=0";
				var ddlKindNo=document.getElementById("<%= ddlKindNo.ClientID %>");
				var Groupid='<%=Request.QueryString["Groupid"] %>';
				var CodeID='<%=Request.QueryString["CodeID"] %>';				
				if(!windowSort||windowSort.closed)
				{
					windowSort=window.open("SortMenu.aspx?KindNo="+ddlKindNo.value+"&CodeID="+CodeID+"&Groupid="+Groupid,"newWin",feature);				
				}
				else
				{
					windowSort.focus();
				}
		
			}
			function fnOK()
			{
			       var form=document.forms["aspnetForm"];
			       var  hidMethod=document.getElementById("<%= hPccMsg.ClientID%>");
			       hidMethod.value="<Method>Refesh</Method>";
			       form.submit(); 
			}
            function fnExchangeSeq(obj)
            {   
                var hChoose=document.getElementById("<%=hChoose.ClientID %>");
                var hPccMsg=document.getElementById("<%=hPccMsg.ClientID %>");
                hChoose.value=parseInt(hChoose.value)+1;
                var MenuID=obj.getAttribute("MenuID");
             
                if(hChoose.value=="1")
                {
                    obj.src="../../Images/Icon/pause.jpeg";
                    hPccMsg.value="<MenuID1>"+MenuID+"</MenuID1>";
                }
                else
                {
                    hChoose.value="0";
                    obj.src="../../Images/Icon/play.png"; 
                    var theForm=document.forms["aspnetForm"];        
                    hPccMsg.value+="<MenuID2>"+MenuID+"</MenuID2><Submit>fnExchangeSeq</Submit>";
                    theForm.submit();
                }
    
}
    </script>

</asp:Content>
